H.264 encoding is a video encoding standard with highest performance currently, and is applied more and more widely. In this encoding scheme, encoding of each image uses a macro block (MB) as a basic encoding unit. A general size of the macro block is a 16×16 pixel unit currently. An important conception of encoding is predictive encoding. That is, encoded image information is used as a reference to predict data of an image that is encoded currently. At the time of encoding, only a difference between current data and predicted data needs to be transmitted. Each-frame image of a video may be encoded by using intra-frame (intra) encoding or inter-frame (inter) encoding. The intra encoding does not use an encoded image for prediction, but uses only information in a current image for prediction.
Intra-frame encoding of a macro block includes block encoding modes, such as 16×16, 8×8, and 4×4. Each kind of mode includes several kinds of prediction modes.
Many prediction modes exist in the H.264. Taking 4×4 as an example, 9 prediction modes are available for selection. Among the 9 prediction modes, except DC prediction (mean prediction), other 8 prediction modes are directional prediction, namely, predicting a current block in a certain direction.
For a DC prediction mode, if surrounding pixels are all unavailable or do not exist, a constant may be used as a prediction value by default. This constant is a mid-value in a dynamic range of an image pixel. For example, for an 8-bit pixel value, a mid-value is 128. In conclusion, in intra encoding, when surrounding pixels are unavailable, only intra DC prediction can be used, and a prediction value must be a mid-value of a pixel.
In a process of implementing the present invention, the inventor finds the prior art has at least the following defects: for a case that only a constant (such as a mid-value of a pixel) can be used for intra-frame prediction in the aforementioned intra DC prediction mode among the DC prediction modes in the prior art, flexibility of intra-frame predictive encoding and decoding is poor; and when a specific image is encoded, a mid-value of a pixel probably deviates from a mid-value, thus causing deterioration of encoding quality.